LIB_TYPE_STATIC=1
LIB_TYPE_SHARED=2

LIB_TYPE=$(LIB_TYPE_SHARED)

ifeq ($(LIB_TYPE_STATIC),$(LIB_TYPE))
TARGET = libcore.a
else
TARGET = libcore.so
endif

# the root path of source files
SRC_ROOT=$(MAKE_ROOT)/src
# the root path of output dir
OUT_ROOT=$(MAKE_ROOT)/out
# the root path of .o files
OBJ_ROOT=$(OUT_ROOT)/obj
# the root path of .d files
DEP_ROOT=$(OUT_ROOT)/dep
# the root path of .a files
LIB_ROOT=$(OUT_ROOT)/lib
# the root path of dependences libs
DEP_LIB_ROOT=$(MAKE_ROOT)/../Dependencies/lib/OSX

# source file's relative dirs of this project, relative to the $(SRC_ROOT)
SRC_RELATIVE_PATHS =  \
$(SPACE) \
EAGL

# .h file's absolute dirs of this project
VPATH = \
$(MAKE_ROOT)/include:\
$(MAKE_ROOT)/include/EAGL:\
$(MAKE_ROOT)/../U2Core/include/Core:\
$(MAKE_ROOT)/../U2Core/include/Core/OSX:\
$(MAKE_ROOT)/../U2Core/include/Core/Threading:\
$(MAKE_ROOT)/../U2Core/include/Math:\
$(MAKE_ROOT)/../U2Core/include/Platform:\
$(MAKE_ROOT)/../U2Core/include/Util:\
$(MAKE_ROOT)/../Dependencies/include/GLES

# source file's absolute dirs of this project
SRC_PATHS=$(addprefix $(SRC_ROOT)/,$(SRC_RELATIVE_PATHS))

# .o file's absolute dirs of this project
OBJ_PATHS=$(addprefix $(OBJ_ROOT)/,$(SRC_RELATIVE_PATHS))

# .d file's absolute dirs of this project
DEP_PATHS=$(addprefix $(DEP_ROOT)/,$(SRC_RELATIVE_PATHS))


# params of build to .o
CC=clang
CCFLAGS=-Wall -g
CCFLAGS+=$(patsubst %,-I%,$(subst :, ,$(VPATH)))
CCFLAGS+=-DDEBUG
CCFLAGS+=-isysroot

DEPFLAGS=-MM
DEPFLAGS+=$(patsubst %,-I%,$(subst :, ,$(VPATH)))

# params of shared lib
LDFLAGS += $(DEP_LIB_ROOT)/GLES/libGLESv1_CM.dylib
LDFLAGS += $(DEP_LIB_ROOT)/GLES/libEGL.dylib
LDFLAGS += -fPIC -shared
LDFLAGS += -framework CoreFoundation
LDFLAGS += -framework QuartzCore
LDFLAGS += -framework UIKit

# params of static lib
AR=ar
ARFLAGS=cr
